package com.tandashi.springbootstudy01.study.thread;

public class NoShareThread extends Thread {
    private int count = 10;

    public NoShareThread(String name) {
        super();
        this.setName(name);
    }

    @Override
    synchronized public void run() {
        super.run();
        while (count > 0) {
            count --;
            System.out.println("由"+ this.currentThread().getName() + "计算,count = "+count);
        }
    }

    public static void main(String[] args) {
        /**
         * A B C 各自有10张票
         */
        NoShareThread t1 = new NoShareThread("A");
        NoShareThread t2 = new NoShareThread("B");
        NoShareThread t3 = new NoShareThread("C");
        t1.start();
        t2.start();
        t3.start();

        /**************A B C 一共有10张票*************/
        /*NoShareThread t1 = new NoShareThread();
        Thread thread1 = new Thread(t1,"A");
        Thread thread2 = new Thread(t1,"B");
        Thread thread3 = new Thread(t1,"C");
        Thread thread4 = new Thread(t1,"D");
        Thread thread5 = new Thread(t1,"E");
        thread1.start();
        thread2.start();
        thread3.start();
        thread4.start();
        thread5.start();*/


    }
}
